package net.pws.oos.web.dto;

import javax.servlet.http.HttpServletRequest;

import net.pws.oos.biz.model.Area;

public class AreaTreeNodeDto extends AbstractTreeNode {
    
    @SuppressWarnings("unchecked")
    public static AreaTreeNodeDto from(Area area,
                                    HttpServletRequest request) {
        AreaTreeNodeDto result = new AreaTreeNodeDto();
        result.metadata.put("id", area.getId());
        result.metadata.put("name", area.getName());
        result.setTitle(area.getName());
        result.data.put("icon", request.getContextPath() + "/images/organ.png");
        if (area.getParent() != null) {
            result.state = "leaf";
            result.metadata.put("type", "city");
       } else {
           result.metadata.put("type", "province");
       }
        return result;
    }
    
    public AreaTreeNodeDto() {
    }
    
}
